# Contributor: Mehdi Chinoune <mehdi.chinoune@hotmail.com>

_realname=pyopengl-accelerate
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
pkgver=3.1.6
_commit=227f9c66976d9f5dadf62b9a97e6beaec84831ca # McFletch does not release bundles on GitHub, therefore we use commit hashes to get specific versions
pkgrel=1
pkgdesc="Acceleration code for PyOpenGL (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32')
url='https://pyopengl.sourceforge.io/'
license=('BSD')
depends=("${MINGW_PACKAGE_PREFIX}-python-pyopengl")
makedepends=("${MINGW_PACKAGE_PREFIX}-python-setuptools"
             "${MINGW_PACKAGE_PREFIX}-cython"
             "${MINGW_PACKAGE_PREFIX}-cc")
source=("https://github.com/mcfletch/pyopengl/archive/${_commit}.tar.gz")
sha256sums=('6b556e5aa2fd6517809e1559593038c99d3318d21155be4de3d18acfef093d40')

build() {
  cp -r "pyopengl-${_commit}/accelerate" "python-build-${MSYSTEM}" && cd "python-build-${MSYSTEM}"

  "${MINGW_PREFIX}"/bin/python setup.py build
}

check() {
  cd "${srcdir}/python-build-${MSYSTEM}"

  "${MINGW_PREFIX}"/bin/python setup.py check
}

package() {
  cd "${srcdir}/python-build-${MSYSTEM}"

  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
    "${MINGW_PREFIX}"/bin/python setup.py install --prefix="${MINGW_PREFIX}" \
      --root="${pkgdir}" --optimize=1 --skip-build

  install -Dm644 license.txt "${pkgdir}${MINGW_PREFIX}/share/licenses/python-${_realname}/LICENSE"
}
